package org.travel_system.mapper;

import org.apache.ibatis.annotations.*;
import org.travel_system.pojo.Complaint;

import java.util.List;

@Mapper
public interface ComplaintMapper {

    //根据id查询
    @Select("SELECT * from complaint where complaint_id=#{id}")
    Complaint getComplaintById(int id);

    //查询投诉信息列表
    @Select("select * from complaint where tourist_id=#{touristId}")
    List<Complaint> getComplaints(Integer touristId);

    //添加投诉
    @Insert("insert into complaint(tourist_id, complaint_content, result_content, complaint_photo, complaint_video, is_approved, is_processed)" +
            " VALUES(#{touristId},#{complaintContent},#{resultContent},#{complaintPhoto},#{complaintVideo},#{isApproved},#{isProcessed})")
    int addComplaint(Complaint complaint);

    //删除投诉
    @Delete("delete from complaint where complaint_id=#{complaintId}")
    int deleteComplaint(Complaint complaint);

    //更新投诉
    @Update("update complaint set is_approved=#{isApproved},is_processed=#{isProcessed} where complaint_id=#{complaintId}")
    int updateComplaint(Complaint complaint);

    //查询所有投诉信息
    @Select("select * from complaint")
    List<Complaint> getAllComplaints();
}
